#pragma once

#include <QtOpenGL>
#include "Primitive.h"

using namespace CAD_CAM;

namespace Curves
{
	QVector<MyVertex> deBoreC2ToBezierC2(QVector<MyVertex> & deBorePoints);
	QVector<MyVertex> bezierC2ToDeboreC2(QVector<MyVertex> & bezierPoints);

	class Curve :
		public CAD_CAM::Primitive
	{
	public:
		Curve(void);
		~Curve(void);

		virtual void DrawDeBore(QGLShaderProgram& shaderProgram, QMatrix4x4& viewMatrix, QMatrix4x4& projectionMatrix);
		void DrawShader(QGLShaderProgram& shaderProgram, QMatrix4x4& viewMatrix, QMatrix4x4& projectionMatrix);
		virtual void addBezierVertex( const QVector3D & v) = 0;
		virtual void addDeBoreVertex( const QVector3D & v) = 0;
		virtual void removeBezierVertex( int indx) = 0;

		QVector<int> getCloseDeBorePointsInRange(QVector3D point, float range);
		void selectDeBorePoint(int i);
		void deselectDeBorePoint(int i);
		void moveDeBoreTo(int i, QVector3D position);

	protected:
		void build();
		const int VerticesMax;

		QVector3D deBorePointsColor;
		QVector3D bezierPointsColor;
		QVector3D curveColor;
		QVector3D selectedDeBorePointsColor;
		QVector3D selectedBezierPointsColor;

		QVector<MyVertex> bezierPoints;
		QVector<MyVertex> deBorePoints;
		
		void refresGpuData(QVector<MyVertex> & points);
	};
}


